package com.util;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class LayData {
    /**
     * 返回状态码 ，0正常
     */
    private Integer code = 0;
    /**
     * 返回的操作结果消息，查询的时候可以为空
     */
    private String msg = "操作成功";
    /**
     * 分页功能使用，总条数
     */
    private Integer count = 100;
    /**
     * 数据库表中的数据
     */
    private Object data;

    public LayData(Integer count, Object data) {
        this.count = count;
        this.data = data;
    }

    public LayData(Object data) {
        this.msg="操作成功";
        this.data = data;
    }

    // success
    public static LayData success(Object data){
        LayData layTableData = new LayData(data);
        System.out.println(layTableData);
        return layTableData;
    }

    public static LayData success(Integer count, Object data){
        return new LayData(count,data);
    }
    // error
    public static LayData error(){
       LayData layTableData = new LayData();
       layTableData.code=1;
       return  layTableData;
    }

}
